<template>
  <div class="goodsDetail">
    <div>
      <div class="mt20">
        <span class="main_active">绑定基站：</span>
        <el-select v-model="formInfo.bsid" class="w400" placeholder="请选择">
          <el-option
            v-for="item in BaseStockData"
            :key="item.BSID"
            :label="'[' + item.BSID + ']' + item.BSName"
            :value="item.BSID"
          />
        </el-select>
      </div>
      <div class="mt20">
        <span class="main_active">屏幕类型：</span>
        <el-select v-model="formInfo.lcdtype" class="w400" placeholder="请选择">
          <el-option
            v-for="item in LCDData"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
      <!-- <div class="mt20">
        <span class="main_active">二代：</span>
        <el-switch
          v-model="formInfo.isESLCode2"
          :active-value="1"
          :inactive-value="0"
        />
      </div> -->
    </div>
    <div class="tableDetail">
      <div class="button-add">
        <el-button size="small" type="primary" @click="addFn()">
          添加行
        </el-button>
        <!-- <el-button size="small" type="danger" @click="deletedchild()">
          删除行
        </el-button> -->
      </div>
      <el-scrollbar
        wrap-class="scrollbar-wrapper"
        wrap-style="overflow-x: auto;"
      >
        <el-table
          ref="multipleTable"
          border
          :data="tableData"
          height="400"
          :row-class-name="tableRowClassName"
          :row-key="getRowKey"
          style="width: 800px"
          @selection-change="handleSelectionChange"
        >
          <!-- <el-table-column prop="value" type="selection" width="55" /> -->
          <!-- <el-table-column label="编号" type="index" width="50" /> -->
          <el-table-column label="射频码">
            <template #default="{ row }">
              <el-input v-model="row.ESLCode" type="text" />
            </template>
          </el-table-column>
          <el-table-column v-if="formInfo.isESLCode2 === 1" label="二代条形码">
            <template #default="{ row }">
              <el-input v-model="row.ESLCode2" type="text" />
            </template>
          </el-table-column>
          <el-table-column label="条形码">
            <template #default="{ row }">
              <el-input v-model="row.UUID" type="text" />
            </template>
          </el-table-column>
          <!-- <el-table-column label="射频码(旧)">
            <template #default="{ row }">
              <el-input v-model="row.eslCodeOld" type="text" />
            </template>
          </el-table-column> -->
        </el-table>
      </el-scrollbar>
    </div>
  </div>
</template>
<script>
  export default {
    name: 'Detail',
    components: {},
    props: {
      form: {
        type: Object,
        default: () => {
          return {}
        },
      },
      basestockdata: {
        type: Array,
        default: () => {
          return []
        },
      },
    },
    emits: ['deletedchild'],
    data() {
      return {
        formInfo: this.form,
        tableData: this.form.chiledData,
        BaseStockData: this.basestockdata,
        LCDData: [
          {
            label: '212*104',
            value: '00',
          },
          {
            label: '200*200',
            value: '01',
          },
          {
            label: '296*152',
            value: '02',
          },
          {
            label: '250*122',
            value: '03',
          },
          {
            label: '880*528',
            value: '04',
          },
          {
            label: '300*400',
            value: '05',
          },
          {
            label: '296*128',
            value: '06',
          },
        ],
      }
    },
    watch: {
      form(val) {
        console.log(val)
        this.formInfo = val
        this.tableData = val.chiledData
      },
    },
    methods: {
      addFn() {
        this.$nextTick(() => {
          this.tableData.push({
            UUID: '',
            ESLCode: '',
            ESLCode2: '',
            eslCodeOld: '',
          })
        })
      },
    },
  }
</script>
<style lang="scss" scoped>
  .goodsDetail {
    min-height: 300px;
  }
  .flex_align {
    display: flex;
    align-items: center;
  }
  .tableDetail {
    padding: 10px;
    .button-add {
      text-align: end;
      padding: 10px;
    }
  }
  .main_active {
    display: inline-block;
    width: 120px;
    text-align: right;
  }
  .mr20 {
    margin-right: 20px;
  }

  .w400 {
    width: 400px !important;
  }
  .mt20 {
    margin-top: 10px;
  }
  .mr10 {
    margin-right: 10px;
  }
  .w320 {
    width: 320px;
  }
  ::v-deep .el-scrollbar__wrap {
    overflow-x: auto;
    height: calc(100% + 20px); //多出来的20px是横向滚动条默认的样式
  }
  ::v-deep .el-scrollbar .el-scrollbar__wrap .el-scrollbar__view {
    white-space: nowrap;
    display: inline-block;
  }
  ::v-deep .el-table--scrollable-x .el-table__body-wrapper {
    overflow-x: hidden;
  }
  ::v-deep input[type='number']::-webkit-inner-spin-button,
  ::v-deep input[type='number']::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
  }
</style>
